import 'package:flutter/material.dart';
import 'package:flutter_common_app/widgets/custom_image/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'empty_view/h_empty_view.dart';
import 'empty_view/v_empty_view.dart';

class SongsListItem extends StatelessWidget {
  final int index;
  final String picUrl;
  final String name;
  final String describe;
  final Function clickPlayCallBack;

  SongsListItem({
    Key key,
    this.index,
    this.name,
    this.describe,
    this.clickPlayCallBack,
    this.picUrl,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(30.w, 20.w, 30.w, 20.w),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Container(
            margin: EdgeInsets.only(left: 20.w),
            child: picUrl == null
                ? Text(
                    '${index + 1}',
                    style: TextStyle(
                      color: Colors.grey,
                      fontSize: 32.sp,
                    ),
                  )
                : CustomImage.network(
                    picUrl,
                    width: 75.w,
                    height: 75.w,
                    borderRadius: BorderRadius.all(
                      Radius.circular(10.w),
                    ),
                  ),
          ),
          HEmptyView(20.w),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  name,
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                  style: TextStyle(
                    color: Colors.black87,
                    fontSize: 30.sp,
                  ),
                ),
                VEmptyView(5.w),
                Text(
                  describe,
                  style: TextStyle(
                    color: Colors.grey,
                    fontSize: 24.sp,
                  ),
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                )
              ],
            ),
          ),
          GestureDetector(
            behavior: HitTestBehavior.opaque,
            onTap: () {
              clickPlayCallBack();
            },
            child: Icon(
              Icons.play_circle_outline,
              color: Colors.grey,
              size: 45.w,
            ),
          ),
          HEmptyView(15.w),
          Icon(
            Icons.more_vert,
            color: Colors.grey,
            size: 45.w,
          ),
        ],
      ),
    );
  }
}
